package ihm;

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import metier.Employe;

import test.MenuPrincipal;
import javax.swing.JTextField;
import javax.swing.event.ListSelectionEvent;

public class FenetreModifierEmploye extends JDialog implements ActionListener
{
	private Container contenu;
	private JButton bAnnuler;
	private JButton bValider;
	private JComboBox cBox;
	
	private ArrayList<Employe> lesEmployes;
	private JTextField txtNom;
	private JTextField txtPrenom;
	private JTextField txtTelephone;
	private JLabel lblNomEmploy;
	private JLabel lblPrenomEmploy;
	private JLabel lblTelephoneEmploy;
	
	public FenetreModifierEmploye (ArrayList<Employe> lesEmployes) 
	{
		setTitle("Modifier Employe");		
		
		this.lesEmployes = lesEmployes;
		cBox = new JComboBox();
		bAnnuler = new JButton("Annuler");
		bValider = new JButton("Valider");		
		this.contenu = this.getContentPane();
		this.contenu.setLayout(null);
		
		contenu.add(bAnnuler);	
	    bAnnuler.addActionListener(this); 
	    contenu.add(bValider);	
	    bValider.addActionListener(this); 
	    
		bAnnuler.setBounds(153,216,100,30);
		bValider.setBounds(263,216,100,30);
		cBox.setBounds(10,10,350,30);
		
		for(Employe unEmploye : this.lesEmployes)
		{
		   cBox.addItem(unEmploye);
		}
		contenu.add(cBox);
		
		txtNom = new JTextField();
		txtNom.setColumns(10);
		txtNom.setBounds(153, 69, 158, 30);
		getContentPane().add(txtNom);
		
		txtPrenom = new JTextField();
		txtPrenom.setColumns(10);
		txtPrenom.setBounds(153, 110, 158, 30);
		getContentPane().add(txtPrenom);
		
		txtTelephone = new JTextField();
		txtTelephone.setColumns(10);
		txtTelephone.setBounds(153, 151, 158, 30);
		getContentPane().add(txtTelephone);
		
		lblNomEmploy = new JLabel("Nom employ\u00E9 :");
		lblNomEmploy.setBounds(39, 77, 88, 14);
		getContentPane().add(lblNomEmploy);
		
		lblPrenomEmploy = new JLabel("Prenom employ\u00E9 :");
		lblPrenomEmploy.setBounds(24, 118, 103, 14);
		getContentPane().add(lblPrenomEmploy);
		
		lblTelephoneEmploy = new JLabel("T\u00E9l\u00E9phone employ\u00E9 :");
		lblTelephoneEmploy.setBounds(10, 159, 117, 14);
		getContentPane().add(lblTelephoneEmploy);
	}
	
	public void actionPerformed(ActionEvent evt)
	{
		// Bouton Annuler
		if(evt.getSource() == bAnnuler)
		{
            this.dispose();
		}	
		
		if(evt.getSource() == bValider)
		{

		}
	}
	
	public void valueChanged(ListSelectionEvent evt)
	{
		if(evt.getSource() == cBox)
		{
			Employe item;
			item = (Employe)cBox.getSelectedItem();
			
		}
	}
}
